
package packagefortest;
import java.io.IOException;

import dijkstra.Dijkstra;
import gdatastructure.AutoBuildGraph;
import gdatastructure.Graph;
import gdatastructure.VNode;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.ListIterator;

public class Main {
    
	public static void main(String[] args) throws IOException {
           
		//测试算法
                long startTime1 = System.currentTimeMillis();//记录开始时间
                int j=0;
		Graph dijkgraph = AutoBuildGraph.buildTestGraphForDijk();  //自动构建图
		Dijkstra dijkalgo = new Dijkstra(dijkgraph); 
                dijkgraph.turnstreet();//创立一个函数，输出所有的街道
                
                dijkgraph.createone();
                 long endTime1 = System.currentTimeMillis();//记录结束时间
                float excTime1 = (float) (endTime1 - startTime1) / 1000;
                System.out.println("预处理执行时间：" + excTime1 + "s");
                BufferedReader in =new BufferedReader(new InputStreamReader( System.in));
                while(true){
                    try{
                        j = Integer.parseInt(in.readLine().trim());
                    }catch(Exception e)
                    {	
                    }
                    if(j==0)
                        break;
                    long startTime = System.currentTimeMillis();//记录开始时间
                    for(int i=0;i<j;i++){
                        dijkgraph.search();
                        dijkgraph.now.showup();
                    }
                    //dijkgraph.changecar();
                    long endTime = System.currentTimeMillis();//记录结束时间
                    float excTime = (float) (endTime - startTime) ;
                    System.out.println("执行时间：" + excTime + "ms");
                }
	}
        /*
 public static void addcir(Graph graph){

        Timer timer = new Timer(); 
        timer.schedule(new TimerTask() {  
            public void run() { 
                int i=1,j=0;
                Iterator<VNode> iterator0 = null;
                 Random random = new Random();
        //        System.out.println("---------------");  
   
         for(i=1;i<=graph.size();i++)
         {
             
             graph.update(i );
         }
                
//                graph.vertexList.get(i).firstEdge.changecir(random.nextInt()%200);
                
               // System.out.print(" "+j+"\n");
            }  
        }, 1000,10000);// 设定指定的时间time,此处为2000毫秒  

    }
 */
    
}
